package com.cat.dataStructure03;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/longest-subsequence-with-non-zero-bitwise-xor/
 * @create 2025/11/6 19:09
 * @since JDK17
 */

public class Solution10 {
    public int longestSubsequence(int[] nums) {
        int n = nums.length, xor = 0, len = nums.length - 1;
        for (int x : nums) {
            xor ^= x;
        }
        if (xor != 0) {
            return n;
        }
        for (int x : nums) {
            if ((x ^ xor) != 0) {
                return n - 1;
            }
        }

        return 0;
    }
}
